/******************************************************************************
 * Name: MemoryManager.h
 * Author: ZhengJuyu
 * Date: 2007/08/25
 * Revision: 
 *
 * Description:
 *
 *****************************************************************************/

#ifndef MEMORYMANAGER_H
#define MEMORYMANAGER_H

#include "crossbit/common.h"
#define ELEMENT_NUM 16

namespace crossbit
{
				class MemoryManager
				{
								public:
												~MemoryManager();

												static MemoryManager* getInstance();
												
												XTMemAddr allocateExecutable(XTUint32 size);

												XTMemAddr allocateObjectPool(XTUint32 * pool_id, XTUint32 pool_size, XTUint32 obj_size);

												XTMemAddr allocateObject(XTUint32 obj_id, XTUint32 size );

								protected:
												MemoryManager();

								private:
												static MemoryManager* instance;

												XTMemAddr pool_exe;
												XTUint32 size_exe;
												XTMemAddr pool;
												XTUint32 size;
												XTMemAddr ele_pool[ELEMENT_NUM];
												XTUint32 ele_size[ELEMENT_NUM];
												XTInt32 ele_curr_ubound;

												static const XTMemAddr POOL_START_EXE = 0xA0000000;
												//128M pool capacity 
												static const XTUint32 POOLSIZE_EXE = 0x2000000;

												static const XTMemAddr POOL_START = 0xA2000000;
												static const XTUint32 POOLSIZE = 0x6000000;
				};
}

#endif	//MEMORYMANAGER_H
